/*Copyright (C) 2009 - 2011 MASSART GAUTHIER

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SNAKE_HEADER
# define SNAKE_HEADER

# define TITRE_SNAKE 			"SNAKE"
# define SNAKE_MAT_X			50
# define SNAKE_MAT_Y			20
# define SNAKE_MAT_ORG_X	(DEFAULT_SCREEN_SIZE_X / 2) - (SNAKE_MAT_X / 2)
# define SNAKE_MAT_ORG_Y	5


/**********************************************************
** Format du fichier de niveau :
**** ' ' : Une case vide
**** '#' : Un mur
**********************************************************/
# define SNAKE_FVIDE    			' '
# define SNAKE_FMUR     			'#'
# define SNAKE_FIMPLACABLE    'x'
/* Touches d'édition de l'éditeur de niveau */
# define SNAKE_KEY_EMUR				'm'
# define SNAKE_KEY_EVIDE			'v'
# define SNAKE_KEY_QUIT 			'0'
/* Couleurs du snake */
# define SNAKE_COL_MUR    		COLOR_WHITE
# define SNAKE_COL_IMPLACABLE	COLOR_RED
/* Carractères affiché du snake */
# define SNAKE_WCH_MUR    		"█"
# define SNAKE_WCH_IMPLACABLE "×"

# define SNAKE_LVLS_FILENAME  "niveaux/snake_officiels.lvl"

typedef enum SNAKE_CASE_T {
	SNAKE_VIDE = 0,
	SNAKE_MUR = 1,
	SNAKE_IMPLACABLE = 2,
} SNAKE_CASE_T;

void snake_menu(void);
void snake_jeu(void);
void snake_affichage_mat(char matrice[1000], char niveau[50], char auteur[100], long vie, long score, long niveau_actuel, long nombre_niveau);
long snake_afficher_barre_vitesse(long vitesse);
void snake_afficher_info(void);
void snake_menu_level_editor();
void snake_create_level();
void snake_choose_level_pack_to_edit();
void snake_choose_level_to_edit(char *filename);
void snake_init_to_default(SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y]);
void snake_edit_level_info(char *lvl_name, char *author_name, size_t len);
int snake_level_editor(SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y]);
int snake_append_to_lvl_pack(char *lvl_pack_filename, SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y], const char *lvl_name, const char *author_name);
int snake_parse_file(char *filename, char level[1000][50], int choix, SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y]);
void snake_save_level(char *level_file, SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y], const char *author_name, const char *level_name);
void snake_display_editor(SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y]);
void snake_display_matrix(SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y]);
void snake_display_case(SNAKE_CASE_T cel);
void snake_edit_matrix(SNAKE_CASE_T matrix[SNAKE_MAT_X][SNAKE_MAT_Y], int key, IPoint *cursor_pos);
void snake_move_cursor(int key, IPoint *cursor_pos);
void snake_refresh_case(IPoint *pos, SNAKE_CASE_T value);
int snake_charger_niveau(long niveau, char *filename, char matrice[1000], char nom_niveau[50], char nom_auteur[100]);

#endif
